
//
//  EmotionPopView.m
//  微博2期
//
//  Created by J on 15/12/16.
//
//

#import "EmotionPopView.h"
#import "Emotion.h"
#import "EmotionButton.h"
@interface EmotionPopView()
@property (weak, nonatomic) IBOutlet EmotionButton *emotionButton;

@end
@implementation EmotionPopView

+ (instancetype)popView
{
    return [[[NSBundle mainBundle]loadNibNamed:@"EmotionPopView" owner:nil options:nil]lastObject];
}


- (void)showFrom:(EmotionButton*)btn{
    if (!btn) return;
    Emotion * emotion =  btn.emotion;//拿到表情
    self.emotionButton.emotion = emotion;

    //给popView传递数据
    UIWindow *window = [[UIApplication sharedApplication].windows lastObject];
    [window addSubview:self];
    CGRect btnFrame =  [btn convertRect:btn.bounds toView:window];//计算出被点击的按钮在window中frame
    self.y = CGRectGetMidY(btnFrame) - self.height;
    self.centerX = CGRectGetMidX(btnFrame);

}

@end
